package com.tiandang.config;

import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Component
public class SessionMap {

  private static final String TOKEN = "token";

  private static Map<String, String> map = new ConcurrentHashMap<>();

  public void register(String token) {
    map.put(TOKEN, token);
  }

  public boolean isLogin(String token) {
    if (StringUtils.isEmpty(token))
      return false;
    return map.containsKey(TOKEN) && map.containsValue(token);
  }

}
